﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

#endregion

namespace Sebastof.Services.Interfaces {
	/// <summary>
	/// A versioning interface to be implemented objects to support concurrency checks.
	/// </summary>
	public interface IVersionedObject {
		#region Public Methods

		/// <summary>
		/// Returns the current version
		/// </summary>
		/// <returns></returns>
		object GetVersion();

		/// <summary>
		/// Checks if the current version matchs the given version
		/// </summary>
		/// <param name="previousVersion"></param>
		/// <returns></returns>		
		bool CurrentVersionMatchs(object previousVersion);

		/// <summary>
		/// Increases the version and returns the new version
		/// </summary>
		/// <returns></returns>
		object IncreaseVersion();

		/// <summary>
		/// Use internally. After submiting changes to the server the object gets a new version. 
		/// This new version must be updated on the client too.
		/// As IncreaseVersion may be non-deterministic we have a SetVersion method here
		/// </summary>
		/// <param name="newVersion"></param>
		void SetVersion(object newVersion);

		#endregion
	}
}